package com.lijian.client.controller;

import com.lijian.client.feign.UserFeign;
import com.lijian.pojo.Menu;
import com.lijian.pojo.Type;
import com.lijian.pojo.User;
import com.lijian.pojo.UserResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/user")
public class UserClientController {

    @Autowired
    private UserFeign userFeign;

    @GetMapping
    public String user(){
        return "user_manage";
    }

    @GetMapping("/findAll")
    @ResponseBody
    public UserResult findAll(@RequestParam Integer page, @RequestParam Integer limit){
        return userFeign.findAll(page, limit);
    }

    @PostMapping("/save")
    public String save(User user){
        userFeign.save(user);
        return "redirect:/user";
    }

    @GetMapping("/deleteById/{id}")
    public String deleteMenuById(@PathVariable Integer id){
        userFeign.delete(id);
        return "redirect:/user";
    }
    @GetMapping("/addUser")
    public String addMenu(){
        return "user_add";
    }

    @GetMapping("/login")
    public String login(){
        return "login";
    }
}
